/**
 * \file  therapy_ranker.h
 * \brief Definition of TherapyRanker class.
 *
 * ASO: Antiviral Sequence Optimizer
 * <http://aso.googlecode.com/>
 * Copyright (C) 2010 Velez Ezequiel, Peralta Andres, FuDePAN
 *
 * This file is part of the ASO project.
 *
 * Contents:       Header file for ASO providing class TherapyRanker.
 *
 * System:         ASO
 * Language:       C++
 *
 * Author:         Velez Ezequiel, Peralta Andres
 * E-Mail:
 *
 * ASO is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * ASO is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with ASO.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef THERAPY_RANKER_H
#define THERAPY_RANKER_H

#include <mili/mili.h>
#include "aso-core/therapy.h"

/*! Definición de ScoredComp */
struct ScoredComp
{
    bool operator()(const Therapy* t1, const Therapy* t2)
    {
        return (t1->back())->scoring() > (t2->back())->scoring();
    }
};

/*! Definicion de la Clase TherapyRanker. */
class TherapyRanker: private Observer<Therapy>, public mili::Ranker<const Therapy*, mili::AddAfterEqual, ScoredComp, mili::DisposalDeletePolicy<const Therapy*> >
{
private:
    //! From TherapyObs:
    virtual void update(const Therapy* t);

public:
    /*! Constructor */
    TherapyRanker(size_t top)
        : mili::Ranker<const Therapy*, mili::AddAfterEqual, ScoredComp, mili::DisposalDeletePolicy<const Therapy*> >::Ranker(top)
    {}

    /*! Destructor */
    ~TherapyRanker()
    {
        this->clear();
    }
    /*! Obtener el Observador */
    Observer<Therapy>* get_observer()
    {
        return this;
    }
};

/*! Iterador del Ranking de Terapias */
typedef mili::CAutonomousIterator<TherapyRanker> RankingIterator;

#endif
